<template>
  <div v-show="closeFlag">
    <div class="k-resume-modal">
      <span class="ksd-resume-close" @click="handleClose"><i class="iconfont icon-shanchu4"></i></span>
      <div class="flex">
        <div class="ksd-base-info  justify-center flex-c align-items w100">
          <h1 class="mb20 fz18">注册用户</h1>
          <div class="input-items"><input placeholder="账号、用户手机" maxlength="20" v-model.trim="form.account" type="text"
                                          class="gda-input gda-input-lg gda-input-empty"></div>
          <div class="input-items"><input placeholder="密码" maxlength="16" v-model.trim="form.password" type="text"
                                          class="gda-input gda-input-lg gda-input-empty"></div>

          <div class="mt20">
            <button type="button"  @click.prevent.stop="handleSubmit"
                    class="gda-btn gda-btn-primary"
                    style="height: 40px;border-radius: 6px"><span>注册用户</span></button>
          </div>
        </div>
      </div>
    </div>
    <div class="k-resume-diaolog"></div>
  </div>
</template>
<script setup>
const emits = defineEmits(["success"])
const closeFlag = ref(false)
const form = ref({
  account: "",
  password: "123456",
})

const handleOpen = async (data) => {
  closeFlag.value = true
}
const handleClose = () => {
  closeFlag.value = false
  form.value = {
    account: "",
    password: "123456"
  }
}

const handleSubmit = debounce(async () => {
  try {
    await useLoginDialog()
    await useRegAdminUserApi(form.value)
    useMessage().success("注册成功")
    emits("success")
    handleClose()
  } catch (e) {
    useMessage().error(e.message)
  }
}, 1000)

defineExpose({
  handleOpen
})
</script>
<style lang="scss" scoped>
.k-resume-diaolog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 199;
  overflow: auto;
  background: rgba(0, 0, 0, 0.5);
}

.ksd-resume-close {
  position: absolute;
  right: 10px;
  top: 5px;
  z-index: 1000;
  cursor: pointer;
}

.k-resume-modal {
  display: inline-block;
  text-align: left;
  vertical-align: middle;
  box-sizing: border-box;
  color: #333;
  font-variant: tabular-nums;
  line-height: 1.5;
  list-style: none;
  font-feature-settings: "tnum";
  border-radius: 8px;
  width: 840px;
  background: #fff;
  position: fixed;
  margin: 0 auto;
  padding: 30px;
  z-index: 200;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  .bannerbox {
    width: 50%;
  }
}

.custom-slick-item {
  position: relative;
  bottom: 6px;
  padding: 0 32px 0;
  background: #f0f6ff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 12px;
}


.guide-team-banner__slick-item {
  display: flex;
  flex: 1 0 0;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  justify-content: center;
  padding: 4px 12px;
  cursor: pointer
}

.guide-team-banner__slick-item:hover .guide-team-banner__slick-item-title, .guide-team-banner__slick-item:hover .guide-team-banner__slick-item-desc {
  color: #2254f4
}

.guide-team-banner__slick-item-title {
  font-weight: bold;
}

.guide-team-banner__slick-item-desc {
  color: #7f8792;
  opacity: .6
}

.ksd-base-info {
  width: 100%;

  button {
    width: 100%;
  }

  .input-items {
    margin-bottom: 15px;
  }
}

.gda-input {
  box-sizing: border-box;
  font-variant: tabular-nums;
  list-style: none;
  font-feature-settings: "tnum";
  position: relative;
  display: inline-block;
  width: 100%;
  height: 35px;
  padding: 4px 16px;
  color: #333;
  font-size: 14px;
  background-image: none;
  border: 2px solid #eff5fe;
  border-radius: 6px;
  transition: all .3s, padding-right 0s;
}
</style>